﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AD.BLL;
using AD.Model;

public partial class Manager_User_PageData_Notice : WebManagerForm
{
    public NoticeMod hepler = new NoticeMod();
    protected void Page_Load(object sender, EventArgs e)
    {
        string action = Request.QueryString["action"];
        if (!string.IsNullOrEmpty(action))
        {
            if (action.Equals("edit"))
            {
                NoticeMod tmp = null;
                string idstr = Request.QueryString["id"];
                if (!Page.IsPostBack)
                {
                     tmp = NoticeBLL.QueryById(idstr);
                    if (tmp != null)
                    {
                        hepler = tmp;
                    }
                }
                else
                {
                     tmp = NoticeBLL.QueryById(idstr);
                    if (tmp != null)
                    {
                        tmp.Title = Request.Params["title"];
                        tmp.Content = Request.Params["content"];
                        tmp.Url = Request.Params["noticeurl"];
                        int effect = NoticeBLL.Update(tmp);
                        hepler=tmp;
                        if (effect > 0)
                        {
                            Alert("修改公告成功!");
                            RedirectNewURL("NoticeList.aspx?action=gopage&pageIndex=1");
                        }
                        else
                            Alert("修改公告失败!");
                    }
                }
            }
            if (action.Equals("add"))
            {

                if (Page.IsPostBack)
                {
                    NoticeMod tmp = new NoticeMod();
                    tmp.Title = Request.Params["title"];
                    tmp.Content = Request.Params["content"];
                    tmp.Url = Request.Params["noticeurl"];
                    int effect = NoticeBLL.Insert(tmp);
                    hepler = tmp;
                    if (effect > 0)
                    {
                        Alert("增加公告成功!");
                        RedirectNewURL("NoticeList.aspx?action=gopage&pageIndex=1");
                    }
                    else
                        Alert("增加公告失败!");
                }
            }
        }
    }
}